/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;

import org.apache.commons.lang3.StringUtils;

import java.util.stream.Stream;

/**
 * 知识库功能模块
 *
 * @author zpy
 * @version 1.0.0
 */
public enum KnowledgeModule {
    /**测评指标**/
    EVAL_TARGET("测评指标", "eval-method-icon"),
    EVAL_METHOD("测评方式", "eval-method-icon"),
    ONSITE_EVAL("现场测评", "onsite-eval-icon"),
    VULNERABILITY_DESC("脆弱性描述模板", "onsite-eval-icon"),
    RISK_DESC("风险描述模板", "onsite-eval-icon"),
    RISK_DEFINITION("风险定义模板", "onsite-eval-icon"),
    SUGGEST("整改建议模板", "onsite-eval-icon");

    private final String name;
    private final String icon;

    KnowledgeModule(String name, String icon){
        this.name = name;
        this.icon = icon;
    }

    public String getName(){
        return this.name;
    }
    public String getIcon(){
        return this.icon;
    }

    public static KnowledgeModule fromName(String name){
        return Stream.of(KnowledgeModule.values())
                .filter(gd-> StringUtils.equals(gd.getName(),name))
                .findFirst().orElse(null);
    }

}